<!DOCTYPE html>
<html lang="en">
<head>
  <meta charset="UTF-8">
  <meta name="viewport" content="width=device-width, initial-scale=1.0">
  <title>Document</title>
</head>
<body>
  <input type="text">
  <button>测试</button>
  <div id="test"></div>
  <script>
    let btn = document.querySelector('button')
    btn.onclick = function(){
      // document.querySelector('input') 获取 input 元素对象
      document.querySelector('input').focus();
    }

    //获取 test 元素
    let test = document.querySelector('#test');

    test.style.width = '200px';

    function fn(){
      test.style.width = '600px';
    }
    // useLayoutEffect 执行的效果
    //同步调用
    // fn();

    // useEffect 执行效果
    setTimeout(() => {
      fn();
    })



  </script>
</body>
</html>